package com.wll.flutter.hybrid;

import android.app.Application;

import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.FlutterEngineCache;
import io.flutter.embedding.engine.dart.DartExecutor;
import io.flutter.view.FlutterMain;

/**
 * created by detachment on 2020/7/30
 */
public class MyApplication extends Application {
    FlutterEngine flutterEngine;
//    DartExecutor.DartEntrypoint dartEntrypoint;
    @Override
    public void onCreate() {
        super.onCreate();
        // Instantiate a FlutterEngine.
        flutterEngine = new FlutterEngine(this);

        // Configure an initial route.
        flutterEngine.getNavigationChannel().setInitialRoute("your/route/here");

//        dartEntrypoint = new DartExecutor.DartEntrypoint(FlutterMain.findAppBundlePath(),
//                "mySpecialEntrypoint");

        // Start executing Dart code to pre-warm the FlutterEngine.
        flutterEngine.getDartExecutor().executeDartEntrypoint(DartExecutor.DartEntrypoint.createDefault());
//        flutterEngine.getDartExecutor().executeDartEntrypoint(dartEntrypoint);

        // Cache the FlutterEngine to be used by FlutterActivity.
        FlutterEngineCache
                .getInstance()
                .put("my_engine_id", flutterEngine);
    }
}
